﻿using BusinessLogicLayer;
using Equin.ApplicationFramework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PresentationLayer
{
    public partial class frmChiTietNV : Form
    {
        public NhanVien NhanVien { get; set; }

        public frmChiTietNV()
        {
            InitializeComponent();
        }

        private void frmChiTietNV_Load(object sender, EventArgs e)
        {
            lblChucVu.Text = lblChucVu.Tag.ToString() + " " + NhanVien.TenChucVu;
            lblChuKyHD.Text = lblChuKyHD.Tag.ToString() + " " + NhanVien.ChuKyHopDong;
            lblCMND.Text = lblCMND.Tag.ToString() + " " + NhanVien.CMND;
            lblDiaChi.Text = lblDiaChi.Tag.ToString() + " " + NhanVien.DiaChi;
            lblEmail.Text = lblEmail.Tag.ToString() + " " + NhanVien.Email;
            lblGioiTinh.Text = lblGioiTinh.Tag + " " + NhanVien.TenGioiTinh;
            lblHoTen.Text = lblHoTen.Tag.ToString() + " " + NhanVien.HoTen;
            lblMaNV.Text = lblMaNV.Tag.ToString() + " " + NhanVien.MaNhanVien;
            lblNgayBDLam.Text = lblNgayBDLam.Tag.ToString() + " " + String.Format("{0:dd/MM/yyyy}", NhanVien.NgayBDLam);
            lblNgayKyHD.Text = lblNgayKyHD.Tag.ToString() + " " + String.Format("{0:dd/MM/yyyy}", NhanVien.NgayKyLaiHD);
            lblNgayNhan.Text = lblNgayNhan.Tag.ToString() + " " + String.Format("{0:dd/MM/yyyy}", NhanVien.NgayNhan);
            lblNgaySinh.Text = lblNgaySinh.Tag.ToString() + " " + String.Format("{0:dd/MM/yyyy}", NhanVien.NgaySinh);
            lblQuanLy.Text = lblQuanLy.Tag.ToString() + " " + NhanVien.TenNVQL;
            lblSDT.Text = lblSDT.Tag.ToString() + " " + NhanVien.SoDienThoai;
            lblTrangThai.Text = lblTrangThai.Tag.ToString() + " " + NhanVien.TrangThai;

            dgvDAHT.AutoGenerateColumns = dgvDAQK.AutoGenerateColumns = dgvKyNang.AutoGenerateColumns = dgvOnSite.AutoGenerateColumns = false;
            dgvOnSite.DataSource = new BindingListView<OnSite>(NhanVien.OnSites.ToList());
            dgvKyNang.DataSource = new BindingListView<KyNang>(NhanVien.KyNangs.ToList());
            dgvDAQK.DataSource = new BindingListView<DuAnQuaKhu>(NhanVien.DuAnQuaKhus.ToList());

            List<DuAn> listDA = new List<DuAn>();
            foreach (var da in NhanVien.DuAns.ToList())
            {
                if (!listDA.Exists(d => d.TenDuAn == da.TenDuAn))
                    listDA.Add(da);
            }
            dgvDAHT.DataSource = new BindingListView<DuAn>(listDA);
        }
    }
}
